package com.tian.service;

import com.tian.entity.RepaymentPlain;
import com.tian.service.LoanCalculatorPlainStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author tianwc  公众号：java后端技术全栈、面试专栏
 * @version 1.0.0
 * @date 2023年09月20日 15:31
 * 在线刷题 1200+题和1000+篇干货文章：<a href="https://woaijava.cc/">博客地址</a>
 * <p>
 * 等额本金
 */
@Slf4j
@Service
public class LoanCalculatorPlainAverageCapitalStrategy implements LoanCalculatorPlainStrategy {
    @Override
    public List<RepaymentPlain> calculator(Integer numberOfPayments, BigDecimal loanAmount, BigDecimal annualInterestRate) {

        return null;
    }
    /*public static void main(String[] args) {
        double loanAmount = 100000; // 贷款金额
        double annualInterestRate = 4.8; // 年利率
        int numberOfPayments = 12; // 还款期数

        double monthlyInterestRate = annualInterestRate / 100 / 12; // 月利率
        double monthlyPayment = loanAmount / numberOfPayments; // 每月还款本金

        System.out.println("还款计划：");
        System.out.println("期数\t本金\t利息\t总额");

        for (int i = 1; i <= numberOfPayments; i++) {
            double interest = loanAmount * monthlyInterestRate * (numberOfPayments - i + 1) / numberOfPayments; // 当期利息
            double totalPayment = monthlyPayment + interest; // 当期总额
            System.out.printf("%d\t%.2f\t%.2f\t%.2f\n", i, monthlyPayment, interest, totalPayment);
        }
    }*/
}